﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Jzy.Core.Common;

namespace FortuneHeaven.DAL.Accounts
{
    public class ScoreHistoryDAL : BaseDAL
    {
        public long GetTotalAddScore(int netBarID)
        {
            string sql = "select isnull(sum(Score),0) from ScoreHistory where NetBarID=@p0 and Score >0 ";
            long sum = dbOper.GetScalar<long>(sql, netBarID);
            return sum;
        }

        public long GetTodayAddScore(int netBarID, DateTime today)
        {
            DateTime begin = today.Date;
            DateTime end = today.Date.AddDays(1);
            string sql = "select isnull(sum(Score),0) from ScoreHistory where NetBarID=@p0 and Score >0 and InputTime between '" + begin + "' and '" + end + "'";
            long sum = dbOper.GetScalar<long>(sql, netBarID);
            return sum;
        }

        public long GetTotalSubScore(int netBarID)
        {
            string sql = "select isnull(sum(Score),0) from ScoreHistory where NetBarID=@p0 and Score <0 ";
            long sum = dbOper.GetScalar<long>(sql, netBarID);
            return sum;
        }

        public long GetTodaySubScore(int netBarID, DateTime today)
        {
            DateTime begin = today.Date;
            DateTime end = today.Date.AddDays(1);
            string sql = "select isnull(sum(Score),0) from ScoreHistory where NetBarID=@p0 and Score <0 and InputTime between '" + begin + "' and '" + end + "'";
            long sum = dbOper.GetScalar<long>(sql, netBarID);
            return sum;
        }
    }

}
